package com.szzg10.pattern.combination;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Menu extends Composite {

	private String message;
	private List<Composite> list;
	
	public Menu(String message) {
		this.message = message;
		list = new ArrayList<Composite>();
	}
	
	@Override
	public void add(Composite composite) {
		list.add(composite);
	}

	@Override
	public void remove(Composite composite) {
		list.remove(composite);
	}

	@Override
	public Iterator<Composite> createIterator() {
		return new MenuIterator(list);
	}

	@Override
	public void print() {
		System.out.println(message);
	}
	
	//---getter and setter---
	public List<Composite> getList() {
		return list;
	}

	public void setList(List<Composite> list) {
		this.list = list;
	}
	
}
